package main

import (
	"encoding/json"
	"log"
	"zg3yk/cmd/rabbitmq"
	"zg3yk/config"
	"zg3yk/inits"
	"zg3yk/interface/dao"
	"zg3yk/interface/models"
	"zg3yk/interface/queue"
)

type Test1 struct {
	Test2 string `json:"test2"`
	Test3 string `json:"test3"`
	Test4 string `json:"test4"`
}

func main() {
	config.ViperDataFs()
	inits.MysqlInit()
	rabbitmq.InitRabbitMq()
	msgs := queue.PublishSub("notification")

	forever := make(chan bool)
	//启用协程处理消息
	go func() {
		for d := range msgs {
			//消息逻辑处理，可以自行设计逻辑
			log.Printf("Received a message: %s", d.Body)

			var room []models.Rooms
			err := json.Unmarshal(d.Body, &room)
			if err != nil {
				return
			}
			dao.FindWhere(&room, &room)

		}
	}()

	log.Printf(" [*] Waiting for messages. To exit press CTRL+C")
	<-forever

}
